<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看App信息页</title>
    <%@ include file="/basePath.jsp" %>
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/>
    <link rel="stylesheet" href="statics/bootstrap/css/bootstrap.css">
</head>
<body>
<script src="statics/js/jquery-3.6.0.js"></script>
<script src="statics/bootstrap/js/bootstrap.js"></script>
<script>
    $(function () {
        $("#categoryLevel1").change(function () {
            $("#categoryLevel2").empty();
            $("#categoryLevel3").empty();
            var fid = $("#categoryLevel1").val();
            $.getJSON("secondLevel/" + fid, function (result) {
                $("<option>").attr("hidden", true).append("请选择").appendTo($("#categoryLevel2"))
                $.each(result.extend.secondLevels, function () {
                    var options = $("<option>").val(this.id).append(this.name);
                    options.appendTo($("#categoryLevel2"));
                })
            })
        })
        $("#categoryLevel2").change(function () {
            $("#categoryLevel3").empty();
            var sid = $("#categoryLevel2").val();
            $.getJSON("thirdLevel/" + sid, function (result) {
                $("<option>").attr("hidden", true).append("请选择").appendTo($("#categoryLevel3"))
                $.each(result.extend.thirdLevels, function () {
                    var options = $("<option>").val(this.id).append(this.name);
                    options.appendTo($("#categoryLevel3"));
                })
            })
        })
        $("#deleteLogo").click(function () {
            $(this).remove();
            $("#logoPathImg").remove();
            $("#logoPath").remove();
            $("#logoPath2").remove();
            var logoFile = $("<input>").attr("type", "file").addClass("form-control col-5").attr("name", "logoPath").attr("id", "logoPath");
            logoFile.appendTo($("#logo"));
            //$("#logoPath").attr("hidden",false);
            return false;
        })
        $("#saveAndCommit").click(function () {
            var action = $(".form").attr("action");
            action = action + "?saveAndCommit=1";
            console.log(action);
            $(".form").attr("action", action);
        })
    })
</script>
<div class="container-fluid" style="min-width: 1000px;">
    <div id="header" class="p-3 border">
        <h1 style="font-size: 18px;">查看App基础信息<small class="ml-3 text-danger">用户：${devName}</small>
        </h1>
    </div>
    <div class="p-3 border">
        <form class="w-75 m-auto form" action="" method="post" enctype="multipart/form-data" style="font-size: 14px;">
                <div class="form-group form-row">
                    <label for="softwareName" class="col-3">软件名称:</label>
                    <input type="text" class="form-control col-5" id="softwareName" name="softwareName"
                           value="${appInfo[0].softwareName}" readonly>
                </div>
                <div class="form-group form-row">
                    <label for="apkName" class="col-3">APK名称:</label>
                    <input type="text" class="form-control col-5" id="apkName" name="apkName"
                           value="${appInfo[0].apkName}" readonly>
                </div>
                <div class="form-group form-row">
                    <label for="supportRom" class="col-3">支持ROM:</label>
                    <input type="text" class="form-control col-5" id="supportRom" name="supportRom"
                           value="${appInfo[0].supportRom}" readonly>
                </div>
                <div class="form-group form-row">
                    <label for="interfaceLanguage" class="col-3">界面语言:</label>
                    <input type="text" class="form-control col-5" id="interfaceLanguage" name="interfaceLanguage"
                           value="${appInfo[0].interfaceLanguage}" readonly>
                </div>
                <div class="form-group form-row">
                    <label for="sofewareSize" class="col-3">软件大小:</label>
                    <input type="text" class="form-control col-5" id="sofewareSize" name="sofewareSize"
                           value="${appInfo[0].sofewareSize}" readonly>
                </div>
                <div class="form-group form-row">
                    <label for="downloads" class="col-3">下载次数:</label>
                    <input type="text" class="form-control col-5" id="downloads" name="downloads"
                           value="${appInfo[0].downloads}" readonly>
                </div>
                <div class="form-group form-row ">
                    <label for="flatformId" class="col-3">所属平台:</label>
                    <input type="text" class="form-control col-5" id="flatformId" name="flatformId"
                           value="${appInfo[0].flatform.flatform}" readonly>
                </div>

            <div class="form-group form-row ">
                <label for="level" class="col-3">所属分类:</label>
                <input type="text" class="form-control col-5" id="level" name="level"
                       value=" ${appInfo[0].categoryLevel1.name} -> ${appInfo[0].categoryLevel2.name} -> ${appInfo[0].categoryLevel3.name}" readonly>
            </div>
            <div class="form-group  form-row">
                <label for="status" class="col-3">APP状态:</label>
                <input type="text" class="form-control col-5" name="status" id="status"
                       value="${appInfo[0].status.status}" readonly>
            </div>
            <div class="form-group  form-row">
                <label for="appInfo" class="col-3">应用简介:</label>
                <textarea class="form-control col-5" cols="50" rows="4" name="appInfo"
                          id="appInfo" readonly>${appInfo[0].appInfo}</textarea>
            </div>
            <div class="form-group  form-row" >
                <label class="col-3">LOGO图片:</label>
                <div id="logo" class="col-9">
                    <c:if test="${logoPathImg != null}">
                        <img class="form-control" style="height: 100px;width: 100px;" name="logoPathImg2"
                             id="logoPathImg"
                             src="${logoPathImg}">
                    </c:if>
                    <c:if test="${logoPathImg == null}">
                        <input type="text"  name="logoPath" id="logoPath2" value="没有添加logo图片" readonly>
                    </c:if>
                </div>
            </div>
        </form>
    </div>
    <div id="resultList" class="border table-responsive p-3">
        <h2 class="p-2">历史版本列表</h2>
        <table class="table table-striped" style="font-size: 14px;">
            <thead>
            <tr>
                <th scope="col">软件名称</th>
                <th scope="col">版本号</th>
                <th scope="col">版本大小(单位：M)</th>
                <th scope="col">发布状态</th>
                <th scope="col">APK文件下载</th>
                <th scope="col">最近更新时间</th>
            </tr>
            </thead>
            <tbody>
            <c:if test="${versions[0] == null}">
                <tr class="text-center">
                    <td colspan="6">
                        还没有添加版本信息哦，请添加版本信息!!!
                    </td>
                </tr>
            </c:if>
            <c:forEach items="${versions}" var="item" >
                <tr>
                    <td>${appInfo[0].softwareName}</td>
                    <td>${item.versionNo}</td>
                    <td>${item.versionSize}</td>
                    <td>${item.publishStatus.publishstatus}</td>
                    <td>${item.apkLocPath}</td>
                    <td>${item.modifyDate}</td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <a class="btn btn-primary" style="width: 100px;margin-left: 400px;margin-top: 50px;margin-bottom: 50px;" href="list/${devId}/${pageNumber}">返回</a>
</div>
</body>
</html>
